
#include "DEV_Config.h"

/**
 * GPIO
**/
int EPD_RST_PIN 	= 33;
int EPD_DC_PIN		= 32;
int EPD_BUSY_PIN	= 40;

int spi_file;

/**
 * GPIO read and write
**/
void DEV_Digital_Write(UWORD Pin, UBYTE Value)
{
	SetValue(Pin, Value);
}

UBYTE DEV_Digital_Read(UWORD Pin)
{
	UBYTE Read_value = 0;

	GetValue(Pin,(int*)&Read_value);

	return Read_value;
}

/**
 * SPI
**/
void DEV_SPI_WriteByte(uint8_t Value)
{
	SPI_Transfer(spi_file, &Value, 1);
}

/**
 * delay x ms
**/
void DEV_Delay_ms(UDOUBLE xms)
{
	usleep(xms*1000);
}


void EPD_Init(void)
{
	spi_file = SPI_Open();

	RegitsterGpio(EPD_RST_PIN);
	SetDirection(EPD_RST_PIN,"out");
	RegitsterGpio(EPD_DC_PIN);
	SetDirection(EPD_DC_PIN,"out");
	RegitsterGpio(EPD_BUSY_PIN);
	SetDirection(EPD_BUSY_PIN,"in");

}

void EPD_Deinit(void)
{
	SPI_Close(spi_file);
	UnregisterGpio(EPD_RST_PIN);
	UnregisterGpio(EPD_DC_PIN);
	UnregisterGpio(EPD_BUSY_PIN);

}


